package com.xggstudio.crm.ui.mvp.v.pop;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.xggstudio.crm.R;
import com.xggstudio.crm.base.App;
import com.xggstudio.crm.ui.mvp.m.AssistList;
import com.xggstudio.crm.ui.mvp.v.adapter.BaseCommonAdapter;
import com.xggstudio.crm.ui.mvp.v.adapter.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class CusAssistPopWindow extends BasePopWindow {

    private RecyclerView list;

    private BaseCommonAdapter adapter;

    public CusAssistPopWindow(Context context , View v) {
        super(context,v);
    }

    @Override
    protected int getLayout() {
        return R.layout.popwindow_cus_type;
    }

    @Override
    protected void init(Context context,View v) {

        list = view.findViewById(R.id.list);


        List<String> data = new ArrayList<>();

        adapter = new BaseCommonAdapter<String>(context,R.layout.view_text,data) {

            @Override
            public void convert(ViewHolder holder, String s, int position) {

                holder.setText(R.id.text,s);

                holder.setOnClickListener(R.id.layout, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                    }
                });

            }
        };

        list.setLayoutManager(new LinearLayoutManager(context));
        list.setAdapter(adapter);

        // showAsDropDown(v,0,0);
        getAssistData();
    }


    private void getAssistData(){

        List<String> list = new ArrayList<>();

        if(App.getInstance().getAssistList() != null){

            AssistList entity = App.getInstance().getAssistList();
            for (int i = 0; i < entity.getResult().size(); i++) {
                AssistList.ResultBean temp = entity.getResult().get(i);
                list.add(temp.getName());
            }


            adapter.addDatas(list);

        }

    }


}
